<template>
  <!-- 新闻列表 卡片样式 -->
  <div
    class="news-item"
    :style="{
      'box-shadow': showBoxShadow ? ' 0 2px 12px 0 rgba(0, 0, 0, 0.1)' : '',
      width: imageWidth,
      marginRight: marginRight,
    }"
  >
    <el-image
      :style="{ width: imageWidth, height: imageHeight }"
      class="news-cover"
      fit="cover"
      :src="newsItem.cover"
    ></el-image>
    <div class="news-content-ws" :style="`--imageWidth: ${imageWidth}`">
      <div class="news-title">
        {{ newsItem.title }}
      </div>
      <div class="news-content">
        {{ newsItem.describe }}
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "skyNewsListCard",
  props: {
    imageWidth: {
      //新闻封面宽度
      type: String,
      default: "300px",
    },
    imageHeight: {
      //新闻封面高度
      type: String,
      default: "200px",
    },
    marginRight: {
      type: String,
      default: "50px",
    },
    showBoxShadow: {
      // 阴影边框
      type: Boolean,
      default: true,
    },
    newsItem: {
      type: Object,
      default: () => {},
    },
  },
};
</script>

<style lang="less" scoped>
.news-item {
  display: inline-block;
  margin: 0 15px 15px 0;
  cursor: pointer;
  box-sizing: border-box;
  .news-content-ws {
    width: var(--imageWidth);
    padding-bottom: 10px;
    box-sizing: border-box;
  }
  .news-cover {
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
  }
  ::v-deep .news-cover:hover {
    img {
      animation: scale 0.5s ease-in forwards;
    }
  }
  @keyframes scale {
    from {
      scale: 1;
    }
    to {
      scale: 1.2;
    }
  }
  .news-title {
    width: 100%;
    font-size: 18px;
    font-weight: bold;
    line-height: 35px;
    padding: 0 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    &:hover {
      text-decoration: underline;
    }
  }
  .news-content {
    font-size: 14px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    height: 42px;
    line-height: 21px;
    padding: 0 10px 20px 10px;
    box-sizing: border-box;
  }
}
</style>